#include <stdio.h>

int main(void) {
    int a, b, c, d, e, f, n;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
    n = 0;
    (a < 100) && (a != 0);
    (b < 100) && (c < 100) && (d < 100) && (e < 100) && (f < 100);
    if (b % a == 0)
        n += b;
    if (c % a == 0)
        n += c;
    if (d % a == 0)
        n += d;
    if (e % a == 0)
        n += e;
    if (f % a == 0)
        n += f;
    printf("%d\n", n);
    return 0;
}


